import Vue from 'vue'
import Vuex from 'vuex'

import {
  sysCourseNotesQuery,
  sysCourseNotesQueryById,
  sysCourseNotesAdd,
  sysCourseNotesUpdate,
  sysCourseNotesDelete,
  sysCourseNotesOpenApiQuery,
} from '@/api/admin/course/sysCourseNotes.js'

Vue.use(Vuex)

const state = {}

const getters = {}

const actions = {
  async querySysCourseNotes({ commit }, listQuery) {
    let res = await sysCourseNotesQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async querySysCourseNotesById({ commit }, id) {
    let res = await sysCourseNotesQueryById(id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async addSysCourseNotes({ commit }, data) {
    let res = await sysCourseNotesAdd(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async updateSysCourseNotes({ commit }, data) {
    let res = await sysCourseNotesUpdate(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async deleteSysCourseNotes({ commit }, id) {
    let res = await sysCourseNotesDelete(id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async queryOpenApiSysCourseNotes({ commit }, listQuery) {
    let res = await sysCourseNotesOpenApiQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
}

const mutations = {}

export default {
  state,
  getters,
  actions,
  mutations,
}
